<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\App;

class ChangeLocale
{
    public function handle($request, Closure $next)
    {
        $language = $request->header('lang');
        if($language == 'ko'){
            $language == 'kr';
        }
        if ($language && in_array($language,config('app.locale_list'))) {

            App::setLocale($language);
        }else{
            $language = config('app.api_locale');
            App::setLocale($language);
        }
        return $next($request);
    }
}
